using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using System.Transactions;
using GC2.Entities.Admin;
using GC2.ExceptionHandler.Services;
using GC2.DataAccess.DAAdmin;

namespace GC2.Bussines.BMAdmin
{
    public class BMVentasDet
    {
        public BMVentasDet(string coneccion) 
        {
            this.Connection = coneccion;
        }

        private string connection = "";
        public string Connection
        {
            get { return connection; }
            set { connection = value; }
        }

        private VentasDet oVentasDet = new VentasDet();
        private List<VentasDet> listaVentasDet = new List<VentasDet>();
        private DAVentasDet daVentasDet = new DAVentasDet();

        #region BMventasDetInsert
        public void BMVentasDetInsert(VentasDet ventasDet)
        {
            try
            {
                daVentasDet.DAVentasDetInsert(connection, ventasDet);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMVentasDetGetAll
        public List<VentasDet> BMVentasDetGetAll(VentasDet ventasDet)
        {
            try
            {
                listaVentasDet = daVentasDet.DAVentasDetGetAll(connection, ventasDet);
                return listaVentasDet;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMVentasDetGetAllByArticulo
        public List<VentasDet> BMVentasDetGetAllByArticulo(VentasDet ventasDet, Ventas ventaD, Ventas ventaH)
        {
            try
            {
                listaVentasDet = daVentasDet.DAVentasDetGetAllByArticulo(connection, ventasDet, ventaD, ventaH);
                return listaVentasDet;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMVentasDetDelete
        public void BMVentasDetDelete(VentasDet ventasDet)
        {
            try
            {
                daVentasDet.DAVentasDetDelete(connection, ventasDet);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion
    }
}
